<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    .img {
        line-height: 10px;
        width: 100px;
        height: 100px;
    }
    </style>
    
</head>
<body>
    <img class=.img src="image/handsomeBoy.jpg" width=50px height=50px>

    <script>
        let img = document.querySelector('img');
        img.onclick = function(){
            console.log(img.src);
            if (img.src.indexOf('handsomeBoy.jpg') >= 0) {
                img.src = 'image/PuppyDog.jpg';
            } else if (img.src.indexOf('PuppyDog.jpg') >= 0) {
                img.src = 'image/handsomeBoy.jpg';
            }
        }
    </script>

</body>
</html>